/**
 * @(#)NoneedLoginUserServiceImpl.java 2017年5月22日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.service.impl;

import org.jsbd.boss.dao.IQQUserDao;
import org.jsbd.boss.domian.channel.QQUser;
import org.jsbd.boss.domian.channel.ThirdUserQueryVo;
import org.jsbd.boss.enums.LoginTypeEnum;
import org.jsbd.boss.util.CacheKey;
import org.jsbd.boss.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * qq用户
 *
 * @author <a href="mailto:xupengcheng@zhexinit.com" >徐鹏程</a>
 * @version 1.0.0
 */
@Service("qqUserService")
public class QQUserServiceImpl extends ThirdLoginAdapterHandler<QQUser> {
    public static final Logger LOGGER = LoggerFactory.getLogger(QQUserServiceImpl.class);


    @Resource
    private IQQUserDao qqUserDao;

    @Override
    public boolean init() {
        loginIndexKey = CacheKey.QQ_LOGIN_INDEX;
        loginType = LoginTypeEnum.QQ_LOGIN;
        queueKey = CacheKey.QQ_USER_QUEUE;
        return true;
    }

    @Override
    public List<QQUser> selectUserList(ThirdUserQueryVo queryVo) {
        Integer start = 0;
        String indexKey = getIndexKey(queryVo.getBase(), queryVo.getApkId(), queryVo.getProvinceId(), queryVo.getCarrier());
        Object indexObj = redisClient.get(indexKey);
        if (indexObj != null) {
            start = Integer.parseInt(indexObj.toString());
        }
        queryVo.setStart(start);
        queryVo.setLength(queryVo.getLength());
        List<QQUser> qqUsers = qqUserDao.selectList(queryVo);
        if (qqUsers != null && !qqUsers.isEmpty()) {
            for (QQUser qqUser : qqUsers) {
                qqUser.setProvince(queryVo.getProvinceId());
            }
        }
        return qqUsers;
    }

}
